// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SourceFile

package com.sgame.android.data;

import android.util.Log;
import com.sgame.android.data.TunnelTransmittable;
import org.json.JSONException;
import org.json.JSONObject;

// Referenced classes of package com.mobage.us.android.data:
//            RewardCampaign

public final class CPIProduct
    implements TunnelTransmittable
{
    public static enum Field
    {

    	PRODUCT_ID, OFFER_ID, APP_KEY, MOBACOIN, CLICK_URL, PROMO_IMAGE_URL, STORE_URL, CAMPAIGN
    }


    public CPIProduct()
    {
    }

    public final void a(JSONObject jsonobject)
    {
        a = jsonobject.optInt(Field.PRODUCT_ID.name());
        b = jsonobject.optString(Field.OFFER_ID.name(), null);
        c = jsonobject.optString(Field.APP_KEY.name(), null);
        d = jsonobject.optInt(Field.MOBACOIN.name());
        e = jsonobject.optString(Field.CLICK_URL.name(), null);
        g = jsonobject.optString(Field.STORE_URL.name(), null);
        f = jsonobject.optString(Field.PROMO_IMAGE_URL.name(), null);
        h = new RewardCampaign();
        h.setFromJson(jsonobject.optJSONObject(Field.CAMPAIGN.name()));
    }

    public final JSONObject toJson()
    {
        JSONObject jsonobject = new JSONObject();
        try
        {
            jsonobject.put(Field.PRODUCT_ID.name(), a);
            jsonobject.put(Field.OFFER_ID.name(), b);
            jsonobject.put(Field.APP_KEY.name(), c);
            jsonobject.put(Field.MOBACOIN.name(), d);
            jsonobject.put(Field.CLICK_URL.name(), e);
            jsonobject.put(Field.STORE_URL.name(), g);
            jsonobject.put(Field.PROMO_IMAGE_URL.name(), f);
            jsonobject.put(Field.CAMPAIGN.name(), h.toJson());
        }
        catch(JSONException jsonexception)
        {
            Log.e("CPIProduct", "Error creating json: ", jsonexception);
        }
        return jsonobject;
    }

    public final String toJsonStringForTunnel()
    {
        return Tunnel.toString("CPIProduct", toJson());
    }

    public final void updateWithJsonObjectFromTunnel(JSONObject jsonObject)
    {
        a(jsonObject);
    }

    public final String a()
    {
        return e;
    }

    public final String b()
    {
        return g;
    }

    private int a;
    private String b;
    private String c;
    private int d;
    private String e;
    private String f;
    private String g;
    private RewardCampaign h;
}
